package com.lgCore.util;/**
 * Created by by on 2020/11/11 15:25
 */

import com.google.protobuf.ByteString;

import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

/**
 * proto ByteString转string
 *@program: sxreader_rpc
 *@author: ligang
 *@create: 2020-11-11 15:25
 */
public class ProtoStringUtil {
    public static ByteString byteToByteString(byte[] bytes){
        return ByteString.copyFrom(bytes);
    }

    public static ByteString stringToByteString(String str){
        return ByteString.copyFrom(str.getBytes());
    }

    public static String byteStringToString(List<ByteString> byteStringList){
        if(byteStringList==null || byteStringList.isEmpty() || byteStringList.size()==0){
            return null;
        }
        return new String(byteStringList.get(0).toByteArray());
    }


    public static void main(String[] args) throws IOException {
        Long datel = 1605974400000L;
        System.out.println(new SimpleDateFormat("yyyy-MM-dd HH:mm").format(new Date(datel)));
    }
}
